/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocio;

import Conexion.Conexion;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author equipo_4
 */
public class DataBase 
{
    public static List<String> tablas(Conexion con)
    {
        try
        {
            List<String> lista = new ArrayList<>();
            String consulta = "SELECT DBA_TABLES.TABLE_NAME FROM SYS.DBA_TABLES WHERE (DBA_TABLES.OWNER = 'BROKER')";
            ResultSet rs = con.EjecutarConsulta(consulta);
            while(rs.next())
            {
                lista.add(rs.getString("TABLE_NAME"));
            }
            return lista;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            return null;
        }        
    }
    
    public static ResultSet Campostabla(String nombreTabla, Conexion con)
    {
        try
        {
            List<String> lista = new ArrayList<>();
            String consulta = "SELECT DBA_TABLES.TABLE_NAME, USER_TAB_COLS.COLUMN_NAME, USER_TAB_COLS.DATA_TYPE FROM SYS.DBA_TABLES, SYS.USER_TAB_COLS WHERE (USER_TAB_COLS.TABLE_NAME = DBA_TABLES.TABLE_NAME) AND (DBA_TABLES.TABLE_NAME ='"+nombreTabla+"') AND (DBA_TABLES.OWNER = 'BROKER')";
            ResultSet rs = con.EjecutarConsulta(consulta);
            return rs;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            return null;
        }        
    }
    
}
